/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-06-09 10:37:55
 * @LastEditTime : 2023-06-09 10:42:11
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\TunnelLength.jsx
 * @Description  :
 */

import { API_LIST } from '../../../Api/Api'
import { commonTableList, BuiltInData } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton } from '../Common/options'
import { TunnelInfos } from '../Common/Conversion'

export const TunnelLength = async ({ url, OptionsEvent, ClientData, Permission }) => {
    const tunnelInfoUuid = await TunnelInfos()
    let data = {
        type: '隧道管理',
        pageSize: 10,
        params: { pageIndex: 1, OrderField: 'tunnelInfoUuid@asc,lorR@asc' },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            Permission.findIndex(v => v.uuid === '0c31c502-92da-443f-a621-be7be92f96f9') !== -1 && (
                <AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />
            ),
        ],
        columns: [
            commonTableList.uuid,
            {
                dataIndex: 'tunnelInfoUuid',
                title: '隧道',
                valueType: 'select',
                valueEnum: tunnelInfoUuid,
                rules: true,
                width: 150,
                hideInSearch: false,
            },
            {
                dataIndex: 'lorR',
                title: '部位',
                valueType: 'select',
                valueEnum: BuiltInData.lorR,
                rules: true,
                width: 150,
                hideInSearch: false,
            },
            {
                dataIndex: 'totalLength',
                title: '总长度',
                valueType: 'inputNumber',
                rules: true,
                width: 150,
                hideInSearch: true,
            },
            {
                dataIndex: 'completedLength',
                title: '完成长度',
                valueType: 'inputNumber',
                rules: true,
                width: 150,
                hideInSearch: true,
            },
            commonTableList.createUserName,
            commonTableList.createTime,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 200,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        Permission.findIndex(v => v.uuid === '42fbe2b6-3e28-406b-b5b6-a70b020950a3') !== -1 && (
                            <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />
                        ),
                        Permission.findIndex(v => v.uuid === '27f1ae8f-bc4d-4e65-a5bd-c76bcf8d5d97') !== -1 && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="del"
                                title="删除"
                                url={url}
                                uuid={record.uuid}
                            />
                        ),
                    ]
                },
            },
        ],
    }

    // data.columns.find(v => v.dataIndex === 'tunnelInfoUuid').valueEnum = await setValueEnumData({
    //   url: 'getTunnelInfos',
    // })

    return data
}
